package com.hk.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.hk.dtos.UserDTO;
import com.hk.service.UserService;

public class UserInsertFrmController extends SimpleFormController{

	private UserService userService;
	
	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	@Override
	protected ModelAndView onSubmit(HttpServletRequest request,
			HttpServletResponse response, Object command, BindException errors)
			throws Exception {
		// TODO Auto-generated method stub
		UserDTO dto=(UserDTO)command;
		
		userService.addUser(dto);
		
		return new ModelAndView("redirect:/userList.cs");
	}
	
	
}
